package xyz.lwm.lazycat.netpipe.service;

import com.mybatisflex.core.service.IService;
import xyz.lwm.lazycat.netpipe.domain.entity.BaseEntity;

import java.util.Date;

/**
 * 基础 service
 *
 * @author lwm
 */
public interface BaseService<T extends BaseEntity> extends IService<T> {

    @Override
    default boolean save(T entity) {
        Date now = new Date();
        entity.setCreateTime(now);
        entity.setUpdateTime(now);
        return IService.super.save(entity);
    }

    @Override
    default boolean updateById(T entity) {
        entity.setUpdateTime(new Date());
        return IService.super.updateById(entity);
    }

}
